package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class jdbcdemo2
{
    public static void main(String[] args) throws ClassNotFoundException, SQLException
    {
        Class.forName("com.mysql.cj.jdbc.Driver");
        System.out.println("正在连接");
        Connection con= DriverManager.getConnection("jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
                "root",
                "root");
        System.out.println("连接成功");
        Statement sa=con.createStatement();
        String sql="INSERT INTO USER(USERNAME,PASSWORD,NICKNAME,AGE) "
                +"VALUES('张三','123456','阿三',22)";
        int count=sa.executeUpdate(sql);
        System.out.println(count>0?"成功":"失败");
        sa.close();
    }
}
